package com.atguigu.spzx.cloud.order.retryers;

import feign.RetryableException;
import feign.Retryer;

/**
 * projectName: com.atguigu.spzx.cloud.order.retryers
 *
 * @author: 顾司羽
 * description:
 */
public class MyRetryer implements Retryer {

    //重试3次
    private  int start = 0 ;
    private  int end   = 10 ;


    //证明链接异常!!  1. 抛出异常 2.生吞异常
    @Override
    public void continueOrPropagate(RetryableException e) {
        System.out.println("重试第"+(start+1)+"次!!!");
        if (start >= end){
            throw new RuntimeException(e);
        }
        start++;
    }


    //返回当前对象
    @Override
    public Retryer clone() {
        return new MyRetryer();
    }
}
